home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5005 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.NetVision.net.il!news
  2. From: david_r@netvision.net.il
  3. Newsgroups: comp.lang.c
  4. Subject: [Q] decleration in header file, text in fwrite/read
  5. Date: Sun, 11 Feb 1996 22:12:49 GMT
  6. Organization: NetVision LTD.
  7. Message-ID: <4flq92$p1u@news.NetVision.net.il>
  8. Reply-To: david_r@netvision.net.il
  9. NNTP-Posting-Host: ts9dp4.netvision.net.il
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12.  
  13. I need to store control file information in a readable text format.
  14. In order to use fread/fwrite, I have declared a special struct which
  15. includes space for the (constant) text headings.  This struct gets the
  16. size needed for the headings by using sizeof on the heading strings.
  17.  
  18. This is (cut to a minimum) what I'm using in a header file, which is
  19. the interface to the functions that handle the control file.
  20.  
  21. ------------------begin bit from ctrl.h----------------------------
  22.  
  23. char str_record_heading[] =  "Record number: ";
  24. char str_EOL[] = "\r\n";
  25.  
  26. typedef struct
  27. {
  28.    char record_heading[ sizeof( str_record_heading) - 1]; /* room for
  29. heading */
  30.    char record[4];                                      /* record
  31. number */
  32.    char yasah_EOL[ sizeof( str_EOL) - 1];
  33. } FILE_CTRL_REC;
  34.  
  35. -----------------------end bit-------------------------------------
  36.  
  37. My problem is that when this is included in more that one file, I get
  38. an error about declaring the strings more than once.  But I have to
  39. know the size of the strings for the declaration of FILE_CTRL_REC.
  40.  
  41. How can I get it to compile?
  42.  
  43. Also, any comments on making the readable control file in this fashion
  44. would be appreciated.
  45.  
  46.  
  47.  
  48.  
  49.  
  50.